package reflect;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Scanner;

public class ReflectDemo5 {
    public static void main(String[] args) throws ClassNotFoundException, InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {

        Scanner sc = new Scanner(System.in);
//        System.out.println("请输入类名：");
//        String className = sc.next();
//        System.out.println("请输入方法名：");
//        String methodName = sc.next();
//        System.out.println("请输入您要输入的参数：");
//        String param = sc.next();
//
//        Class cls = Class.forName(className);
//        Object obj = cls.newInstance();
//
//        Method method = cls.getMethod(methodName,String.class);
//        method.invoke(obj,param);

        System.out.println("请输入类名：");
        String className = sc.nextLine();
        System.out.println("请输入方法名：");
        String methodName = sc.nextLine();
        System.out.println("输入参数：");
        String param = sc.nextLine();

        Class cls = Class.forName(className);
        Object obj = cls.newInstance();

        Method method = cls.getMethod(methodName,String.class, int.class);
        method.invoke(obj,param, 10);








    }
}
